package com.ruoyi.dictionaries.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dictionaries.domain.StudentStatusChange;
import com.ruoyi.dictionaries.service.IStudentStatusChangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学籍异动申请Controller
 *
 * @author gdslovehy
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/dictionaries/studentChange")
public class StudentStatusChangeController extends BaseController
{
    @Autowired
    private IStudentStatusChangeService studentStatusChangeService;

    /**
     * 查询学籍异动申请列表
     */
    //@PreAuthorize("@ss.hasPermi('dictionaries:studentChange:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentStatusChange studentStatusChange)
    {
        startPage();
        List<StudentStatusChange> list = studentStatusChangeService.selectStudentStatusChangeList(studentStatusChange);
        return getDataTable(list);
    }

    /**
     * 导出学籍异动申请列表
     */
    @PreAuthorize("@ss.hasPermi('dictionaries:studentChange:export')")
    @Log(title = "学籍异动申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentStatusChange studentStatusChange)
    {
        List<StudentStatusChange> list = studentStatusChangeService.selectStudentStatusChangeList(studentStatusChange);
        ExcelUtil<StudentStatusChange> util = new ExcelUtil<StudentStatusChange>(StudentStatusChange.class);
        util.exportExcel(response, list, "学籍异动申请数据");
    }

    /**
     * 获取学籍异动申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('dictionaries:studentChange:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(studentStatusChangeService.selectStudentStatusChangeById(id));
    }

    /**
     * 新增学籍异动申请
     */
    @PreAuthorize("@ss.hasPermi('dictionaries:studentChange:add')")
    @Log(title = "学籍异动申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentStatusChange studentStatusChange)
    {
        studentStatusChange.setId(IdUtils.fastSimpleUUID());
        return toAjax(studentStatusChangeService.insertStudentStatusChange(studentStatusChange));
    }

    /**
     * 修改学籍异动申请
     */
    @PreAuthorize("@ss.hasPermi('dictionaries:studentChange:edit')")
    @Log(title = "学籍异动申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentStatusChange studentStatusChange)
    {
        return toAjax(studentStatusChangeService.updateStudentStatusChange(studentStatusChange));
    }

    /**
     * 删除学籍异动申请
     */
    @PreAuthorize("@ss.hasPermi('dictionaries:studentChange:remove')")
    @Log(title = "学籍异动申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(studentStatusChangeService.deleteStudentStatusChangeByIds(ids));
    }
}
